libname inn 'D:\Amazon Price Dynamics\New Data\GAM + MVRF\Other categories\Luggage';
data final_gam_modeldata;
SET inn.final_gam_modeldata_luggage;
run;

proc contents data = final_gam_modeldata;
run;
proc univariate data = final_gam_modeldata;
var 
/*Sales_Rank_Own_Categ_olympia*/
Sales_Rank_Sub_categ_olympia
/*Sales_Rank_Own_Categ_tc*/
Sales_Rank_Sub_categ_tc
/*Sales_Rank_Own_Categ_smsnite*/
Sales_Rank_Sub_categ_smsnite
;
run;
/**using junglescout estimator: sales rank to monthly sales in home and kitchen**/
/***https://www.junglescout.com/estimator/**/
/**monthly sales  @ rank 1 = 298,020, **/
/**monthly sales  @ rank 2 = 220,680, **/
/**monthly sales  @ rank 3 = 185,520, **/
/**monthly sales  @ rank 5 = 149,400, **/
/**monthly sales  @ rank 7 = 129,690, **/
/**monthly sales  @ rank 9 = 116,730, **/
/**monthly sales  @ rank 10 = 111,720, **/
/**monthly sales  @ rank 13 = 100,170, **/
/**monthly sales @ rank 15 = 94,380, **/
/**monthly sales @ rank 17 = 89,610,**/
/**monthly sales  @ rank 20 = 83,760,**/

data modelsales_estimator;
input sales_rank monthly_sales;
cards;
1  298020
2  220680
3  185520
5  149400
7  129690
9  116730
10  11172
13  10017
5  94380
7  89610
20  83760
;
run;

data model_dailysales_estimator;
set modelsales_estimator;
daily_sales = monthly_sales/30;
Y = log(daily_sales + 1);
X = log(sales_rank);
run;
/**using Ghose and Sundarajan's model for demand (Q) - sales rank conversion**/
/**log(Q+1) = log(alpha) + beta*log(sales rank)**/
proc reg data = model_dailysales_estimator;
 model Y = X;
 run;
 /** Parameter Estimates 
Variable DF Parameter Estimate Standard Error t Value Pr > |t| 
Intercept 1 9.46819            0.60812        15.57    <.0001 
X         1 -0.86659           0.31841        -2.72    0.0235 
**/



/**Olympia and Travelers Choice as examples**/

	data oly_sales (keep = time1 Sales_Rank_Sub_categ_olympia buyboxprice_olympia buyboxprice_olympia_lag1);
	set FINAL_GAM_MODELDATA;
	where Sales_Rank_Sub_categ_olympia > 0;
	run;


		data tc_sales (keep = time1 Sales_Rank_Sub_categ_tc buyboxprice_tc buyboxprice_tc_lag1);
	set FINAL_GAM_MODELDATA;
	where Sales_Rank_Sub_categ_tc > 0;
	run;


	data totsales_oly;
set oly_sales;
daily_sales_oly = exp(9.46819 - 0.86659*log(Sales_Rank_Sub_categ_olympia)) -1;
RUN;
data totsales_tc;
set tc_sales;
daily_sales_tc = exp(9.46819 - 0.86659*log(Sales_Rank_Sub_categ_tc)) -1;
RUN;


/**modeling sales as a function of buy box price - current and 1 period lag***/

/***Olympia****/
proc reg data = totsales_oly;
model daily_sales_oly = 
buyboxprice_olympia buyboxprice_olympia_lag1
;
run;


/***TC****/
proc reg data = totsales_tc;
model daily_sales_tc = 
buyboxprice_tc buyboxprice_tc_lag1;
run;
quit;
